const BASE_URL = uni.getStorageSync("BASE_URL")
export const http = function(option) {
	return new Promise((resolve,reject) => {
		uni.request({
			url : BASE_URL + option.url,
			method: option.method || "GET",
			data: option.data,
			header:{
				Authorization : uni.getStorageSync("token")
			},
			success(res) {
				if(res == ""){
					return uni.showToast({
						icon:"error",
						title:"获取数据失败"
					})
				}
				resolve(res)
			},
			fail(err) {
				reject(err)
				return uni.showToast({
					icon:"error",
					title:"请求失败"
				})
			}
		})
	}) 
}
export const getImg = (imgUrl) => BASE_URL + imgUrl